package Payload;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.ws.Provider;
import javax.xml.ws.WebServiceProvider;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

@WebServiceProvider(wsdlLocation="home/jerome/Bureau/InfoEntrTP2/InfoEntr3/edit/editEntreprise.wsdl") 
public class MyPayloadProvider implements Provider<Source>{
	public Source invoke(Source source) {
		try {
		TransformerFactory factory = TransformerFactory.newInstance();
		Transformer t = factory.newTransformer();
		t.transform(source, new StreamResult(System.out));
		DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder = dbFactory.newDocumentBuilder();
		Document response = builder.newDocument();
		Element racine = response.createElementNS("http://www.leuville.com/formation","inscriptionResponse");
		response.appendChild(racine);
		Element inscrit = response.createElementNS("http://www.leuville.com/formation","inscrit");
		inscrit.appendChild(response.createTextNode("true"));
		racine.appendChild(inscrit);
		return new DOMSource(response);
		}catch (Exception ex) {
		ex.printStackTrace();
		return null;
		}
		}


}
